package com.ruoyi.web.controller.applet;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.HospitalSubscribeSetMeal;
import com.ruoyi.system.domain.HospitalSubscribeUserMessage;
import com.ruoyi.system.service.IHospitalSubscribeUserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户消息Controller
 * 
 * @author ruoyi
 * @date 2025-04-30
 */
@RestController
@RequestMapping("/applet/message")
public class HospitalSubscribeUserMessageAppletController extends BaseController
{
    @Autowired
    private IHospitalSubscribeUserMessageService hospitalSubscribeUserMessageService;

    /**
     * 查询用户消息列表
     * @response {@link HospitalSubscribeUserMessage}
     */
    @GetMapping("/list")
    public TableDataInfo list(HospitalSubscribeUserMessage hospitalSubscribeUserMessage)
    {
        startPage();
        hospitalSubscribeUserMessage.setUserId(SecurityUtils.getUserId());
        List<HospitalSubscribeUserMessage> list = hospitalSubscribeUserMessageService.selectHospitalSubscribeUserMessageList(hospitalSubscribeUserMessage);
        return getDataTable(list);
    }

    /**
     * 获取用户消息详细信息
     * @response {@link HospitalSubscribeUserMessage}
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        HospitalSubscribeUserMessage hospitalSubscribeUserMessage = new HospitalSubscribeUserMessage();
        hospitalSubscribeUserMessage.setIsRead(1);
        hospitalSubscribeUserMessageService.updateHospitalSubscribeUserMessage(hospitalSubscribeUserMessage);
        return success(hospitalSubscribeUserMessageService.selectHospitalSubscribeUserMessageById(id));
    }
}
